package com.epoch.zuul.auth.controller;

import bean.response.ResponseBean;
import com.epoch.zuul.auth.service.AuthRoleService;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 *
 * @author Seven
 * @date 2021/12/4
 */
@RestController
public class AuthRoleController {

    @Autowired
    private AuthRoleService authRoleService;

    @RequiresPermissions("auth:getList")
    @ApiOperation(value = "用户版块")
    @GetMapping("epoch/role/authRole/getAuthListByRoleName")
    public ResponseBean getAuthListByRoleName(){
        return authRoleService.getAuthListByRoleName();
    }

    @RequiresPermissions("auth:update")
    @ApiOperation(value = "用户版块")
    @PostMapping("epoch/role/authRole/updateAuthByRoleId/{roleName}/{rids}")
    public ResponseBean updateAuthByRoleId(@PathVariable("roleName") String roleName,@PathVariable("rids") String rids){
        System.out.println(roleName);
        System.out.println(rids);
        return authRoleService.updateAuthByRoleId(roleName,rids);
    }

    /**
     * 根据 roleName authId 删除用户权限
     * @param roleName
     * @param authId
     * @return
     */
    @RequiresPermissions("auth:delete")
    @ApiOperation(value = "用户版块")
    @DeleteMapping("epoch/role/authRole/deleteAuthByRoleIdAuthId/{roleName}/{authId}")
    public ResponseBean deleteAuthByRoleIdAuthId(@PathVariable("roleName") String roleName, @PathVariable("authId") Integer authId){
        return authRoleService.deleteAuthByRoleIdAuthId(roleName, authId);
    }

    @ApiOperation(value = "用户版块")
    @GetMapping("epoch/role/authRole/getMenu/{csPhone}")
    public ResponseBean getMenu(@PathVariable("csPhone") String csPhone){
        return authRoleService.getMenu(csPhone);
    }
}
